---
description: "Reference for Nitric's Go library - Store a key value pair in a key value store."
---

# Go - Kv.Set()

<Note>
  This is reference documentation for the Nitric Go SDK. To learn about
  Key/Value Stores in Nitric start with the [Key/Value Store docs](/keyvalue).
</Note>

Store a key value pair in a key value store.

```go
import (
  "context"
  "fmt"

  "github.com/nitrictech/go-sdk/nitric"
  "github.com/nitrictech/go-sdk/nitric/keyvalue"
)

func main() {
  // Initialize the KV service
  profiles := nitric.NewKv("profiles").Allow(keyvalue.KvStoreSet)

  err := profiles.Set(context.Background(), "profile-1a2b3c", map[string]interface{}{
    "name": "John Smith",
  })
  if err != nil {
    fmt.Println(err)
  }

  nitric.Run()
}
```

## Parameters

<Properties>
  <Property name="ctx" required type="context">
    The context of the call, used for tracing.
  </Property>
  <Property name="key" required type="string">
    The key that references value.
  </Property>
  <Property name="value" required type="map[string]interface{}">
    A json serializable object that is stored as the value.
  </Property>
</Properties>

## Examples

### Set a key value pair

```go
import (
	"context"
	"fmt"

	"github.com/nitrictech/go-sdk/nitric"
	"github.com/nitrictech/go-sdk/nitric/keyvalue"
)

func main() {
	// Initialize the KV service
	profiles := nitric.NewKv("profiles").Allow(keyvalue.KvStoreSet)

	err := profiles.Set(context.Background(), "profile-1a2b3c", map[string]interface{}{
		"name": "John Smith",
	})
	if err != nil {
		fmt.Println(err)
	}

	nitric.Run()
}
```
